package com.print.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="ITEM")
public class Item {
	long idItem;
	String name;
	int prezzoStampa;
	int prezzoOrdine;
	String image;
	Set<UserItem> userItems = new  HashSet<UserItem>();
	
	public Item() {}
	
	public Item(long idItem, String name, int prezzoStampa, int prezzoOrdine, String image, Set<UserItem> userItems) {
		this.idItem = idItem;
		this.image = image;
		this.name = name;
		this.prezzoOrdine = prezzoOrdine;
		this.prezzoStampa = prezzoStampa;
		this.userItems = userItems;
	}
	
	@Id
	@GeneratedValue
	@Column(name="ITEM_ID")
	public long getIdItem() {
		return idItem;
	}
	
	@Column(name="ITEM_IMAGE")
	public String getImage() {
		return image;
	}
	
	@Column(name="ITEM_NAME")
	public String getName() {
		return name;
	}
	
	@Column(name="ITEM_PREZZO_STAMPA")
	public int getPrezzoStampa() {
		return prezzoStampa;
	}
	
	@Column(name="ITEM_PREZZO_ORDINE")
	public int getPrezzoOrdine() {
		return prezzoOrdine;
	}
	
	@OneToMany(mappedBy="item", fetch=FetchType.EAGER)
	public Set<UserItem> getUserItems() {
		return userItems;
	}
	
	public void setIdItem(long idItem) {
		this.idItem = idItem;
	}
	
	public void setPrezzoOrdine(int prezzoOrdine) {
		this.prezzoOrdine = prezzoOrdine;
	}
	
	public void setImage(String image) {
		this.image = image;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public void setPrezzoStampa(int prezzo) {
		this.prezzoStampa = prezzo;
	}
	
	public void setUserItems(Set<UserItem> userItems) {
		this.userItems = userItems;
	}
	
	public void setUserItems(UserItem userItem) {
		this.userItems.add(userItem);
	}
}